home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-05-21 | 4.3 KB | 176 lines |
- /* $Id: Location.java,v 1.6 1996/03/31 11:43:02 djun Exp djun $
-
- File: Location.java
-
- Defines the class Location, which is the key object for the
- GIS. Each map consists of a bunch of locations; each location is
- embedded in some map.
-
- Author: Djun M. Kim
- Copyright (c) 1996 Djun M. Kim. All rights reserved.
-
-
- */
-
- import Map;
- import MapError;
- import java.net.*;
- import java.awt.*;
- import java.util.Vector;
-
- public class Location extends Object {
-
- protected Map parent;
-
- protected Point base; // base coordinate of the location
- protected Region region; // perimeter of the region
- protected String name; // name of the location
- protected URL url; // hyperlink
- protected Map detail; // detail map of location
- protected Vector entrances; // carriers entering this location
- protected Vector exits; // carriers leaving this location
- protected Image mapimg; // map image of the location
- protected String infotext; // text describing the location
- protected Vector keywords; // keyword strings used to do lookups
-
- protected boolean displayable; // does it make sense to display this location?
-
- protected MapError error_handler = new MapError();
-
- // Constructor
- Location(Map target, Point p) {
- this.parent = target;
- base = new Point(p.x, p.y);
- name = new String();
- region = new Region();
- exits = new Vector();
- entrances = new Vector();
- }
-
- // Constructor
- Location(Map target, int x, int y) {
- this(target, new Point(x, y));
- }
-
- /*--------- Accessor Methods -------- */
-
- // base coordinate of the location
- public Point getBase() {return(base);};
- public void setBase(Point p) {base = p;};
-
- // perimeter of the region
- public Region getRegion() {return(region);};
- public void setRegion(Region r) {
- region = r;
- };
-
- // name of the location
- public String getName() {
- return(name);
- };
-
- public void setName(String s) {
- name = s;
- parent.registerLocation(s, this);
- parent.registerKeyword(s, this);
- };
-
- // hyperlink;
- public URL getURL() {return(url);};
- // Assume that url's url and u are good...
- public void setURL(String urlstring) {
- try {
- url = new URL(urlstring);
- } catch (java.net.MalformedURLException e) {
- error_handler.display("Malformed URL Exception: " + e.getMessage());
- };
- };
-
-
- // detail map of location
- public Map getDetailMap() {return(detail);};
- public void setDetailMap(Map m) {
- detail = new Map();
- detail = m;
- };
-
- // entrances
- public Vector getEntrances() {return(entrances);};
- public void setEntrances(Vector vec) {entrances = vec;};
- public void addEntrance(Carrier c) {entrances.addElement(c);};
-
- // exits
- public Vector getExits() {return(exits);};
- public void setExits(Vector vec) {exits = vec;};
- public void addExit(Carrier c) {exits.addElement(c);};
-
- // map image of the location ;
- public Image getMapimg() {return(mapimg);};
- // this will have to change...
- public void setMapimg(Image i) {mapimg = i;};
-
- // text describing the location
- public String getInfoText() {return(infotext);};
- public void setInfoText(String s) {
- infotext = new String(s);
- };
- public void appendtoInfoText(String s) {
- if (infotext == null) {
- infotext = new String(s);
- } else {
- infotext = infotext + s + "\n";
- parent.registerKeyword(s, this);
- }
- };
-
- public boolean isDisplayable() {
- return displayable;
- }
- public void setDisplayable(boolean b) {
- displayable = b;
- }
-
- /* --------- Keyword definitions and lookups -----------*/
-
- // array of keyword strings used to do lookups
- public Vector getKeywords() {return(keywords);};
-
- public void initKeywords() {keywords = new Vector();};
-
- public void addKeyword(String keyword) {
- keywords.addElement(keyword);
- parent.registerKeyword(keyword, this);
- };
-
- }
-
- class Road extends Location {
-
- Road(Map target, int x, int y) {
- super(target, x, y);
- }
- }
-
-
- class Building extends Location {
-
- Building(Map target, int x, int y) {
- super(target, x, y);
- super.setDisplayable(true);
- }
-
- Building(Map target, Point p) {
- super(target, p);
- super.setDisplayable(true);
- }
- }
-
- class Park extends Location {
-
- Park(Map target, int x, int y) {
- super(target, x, y);
- super.setDisplayable(true);
- }
- }
-
-